﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Gozib.Web.Models.Bus
{
    public class DummyDataRespository
    {
        public static BusResultModel GetBusResult()
        {
            var results = new BusResultModel();

            results.BusResults = new List<BusResult>()
            {
                new BusResult()
                {
                    Id = 1001,
                    RouteScheduleId = "0000001",
                    CompanyName = "XYZ",
                    DepartureDate ="12-02-2013",
                    DepartureTime= "7:20 AM",
                    ArrivalDate ="13-02-2013",
                    ArrivalTime = "09:20 PM",
                    Seats = 10,
                    Amenities= "Vedio, Audio",
                    Fare = 250,
                    BusItemTypes = new List<string>{"Ac", "Non-Ac"},
                    /*CancellationPolicy = new List<string>{"Can1xxxxxxxxssdfssxxxxxxxxxxxxxxxxxxxxxxx", "Can2xxxxxxxxxxxxxxxxxxxxxxxx", "Can3xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},
                    BordingPoints = new List<BordingPoint>
                    {
                        new BordingPoint{ BordingPointId = 00011, BordingPointName = "point 11"},
                        new BordingPoint{ BordingPointId = 00012, BordingPointName = "point 12"},
                    }*/
                },
                new BusResult()
                {
                    Id = 1002,
                    CompanyName = "SPN Tours & Travel Sleeper/AC",
                    RouteScheduleId = "0000002",
                    DepartureDate ="12-02-2013",
                    DepartureTime = "08:10 AM",
                    ArrivalDate ="13-02-2013",
                    ArrivalTime = "10:20 PM",
                    Seats = 30,
                    Amenities= "Sleeper, Audio",
                    Fare = 500,
                    BusItemTypes = new List<string>{"Non-Ac"},
                },
                new BusResult()
                {
                    Id = 1003,
                    CompanyName = "AAA",
                    RouteScheduleId = "0000003",
                    DepartureDate ="12-02-2013",
                    DepartureTime = "08:20 PM",
                    ArrivalDate ="13-02-2013",
                    ArrivalTime = "10:20 PM",
                    Seats = 40,
                    Amenities= "Seeter",
                    Fare = 400,
                    BusItemTypes = new List<string>{"Ac", "Non-Aac"},
                },
                new BusResult()
                {
                    Id = 1004,
                    CompanyName = "MMM",
                    RouteScheduleId = "0000004",
                    DepartureDate ="12-02-2013",
                    DepartureTime = "07:20 PM",
                    ArrivalDate ="13-02-2013",
                    ArrivalTime = "6:20 PM",
                    Seats = 50,
                    Amenities= "Seater, Coach",
                    Fare = 800,
                    BusItemTypes = new List<string>{"Ac"},
                }
            };

            results.MinFare = results.BusResults.Min(x => x.Fare);
            results.MaxFare = results.BusResults.Max(x => x.Fare);
            results.AvailableFares = results.BusResults.Select(x => x.Fare).ToList().OrderBy(x => x).Distinct().ToList();
            results.BusTypes = new List<string> { "Ac", "Non-Ac" }; //TODO
            results.BusOperators = results.BusResults.Select(x => x.CompanyName).Distinct().ToList();
            results.FromCityId = "99999";
            results.FromCityName = "Delhi";
            results.ToCityId = "88888";
            results.ToCityName = "Mumbai";
            results.JourneyDate = "2013-6-30";
            return results;
        }

        public static IEnumerable<CityResultModel> GetCities(string terms)
        {
            var cityList=new List<CityResultModel>
            {
                new CityResultModel {CityId =101, CityName="New Delhi" , StateName ="Delhi"},
                new CityResultModel {CityId =102, CityName="Banglore" , StateName ="Karnatka"},
                new CityResultModel {CityId =103, CityName="Mumbai" , StateName ="Maharastra"},
                new CityResultModel {CityId =104, CityName="Pune" , StateName ="Maharastra"},
                new CityResultModel {CityId =105, CityName="Agra" , StateName ="Uttar Pradesh"},
                new CityResultModel {CityId =106, CityName="Chennai" , StateName ="Tamil Nadu"},
                new CityResultModel {CityId =107, CityName="Kerala" , StateName ="Kerala"}
            };

            return cityList.Where(x => x.CityName.ToLower().StartsWith(terms.ToLower()) ||
                        x.StateName.ToLower().StartsWith(terms.ToLower()));
        }

        public static BusSeatMapModel GetSeatMap(string routeScheduleId)
        {
            if (routeScheduleId == "0000001")
            {
                var seat = new BusSeatMapModel();
                seat.RouteScheduleId = "00000001";
                seat.CompanyName = "AAA";
                seat.SeatMaxLowerColumn = 10;
                seat.SeatMaxLowerRows = 4;
                seat.SeatMaxUpperColumn = 10;
                seat.SeatMaxUpperRows = 4;
                seat.CancellationPolicy = new List<string> { "Can1", "Can1", "Can1" };
                seat.BordingPoints = new List<BordingPoint>
                {
                    new BordingPoint{ BordingPointId = 1, BordingPointName = "Bp11"},
                    new BordingPoint{ BordingPointId = 2, BordingPointName = "Bp12"},
                };

                seat.LowerDeck =new List<SeatLayout>
                {
                    new SeatLayout { Fare = 101, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S1", Row=0, Column= 0},
                    new SeatLayout { Fare = 102, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S2", Row=0, Column= 1},
                    new SeatLayout { Fare = 103, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S3" , Row=0, Column= 2},
                    new SeatLayout { Fare = 104, Gender= "F", IsAvailable = true, IsSleeper= false, SeatNo = "S4", Row=0, Column= 3},
                    new SeatLayout { Fare = 105, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S5", Row=0, Column= 4},
                    new SeatLayout { Fare = 106, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S6", Row=0, Column= 5},
                    new SeatLayout { Fare = 107, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S7", Row=0, Column= 6},
                    new SeatLayout { Fare = 108, Gender= "F", IsAvailable = true, IsSleeper= false, SeatNo = "S8", Row=0, Column= 7},
                    new SeatLayout { Fare = 109, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S9", Row=0, Column= 8},
                    new SeatLayout { Fare = 110, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S10", Row=0, Column= 9},
                    new SeatLayout { Fare = 111, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S11", Row=1, Column= 0},
                    new SeatLayout { Fare = 112, Gender= "F", IsAvailable = false, IsSleeper= false, SeatNo = "S12", Row=1, Column= 1},
                    new SeatLayout { Fare = 113, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S13", Row=1, Column=2},
                    new SeatLayout { Fare = 114, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S14", Row=1, Column=3},
                    new SeatLayout { Fare = 115, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S15", Row=1, Column=4},
                    new SeatLayout { Fare = 116, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S16", Row=1, Column=5},
                    new SeatLayout { Fare = 117, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S17", Row=1, Column=6},
                    new SeatLayout { Fare = 118, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S18", Row=1, Column=7},
                    new SeatLayout { Fare = 119, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S19", Row=1, Column=8},
                    new SeatLayout { Fare = 120, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S20", Row=1, Column=9}
                };

                seat.UpperDeck = new List<SeatLayout>
                {
                    new SeatLayout { Fare = 101, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S1", Row=0, Column= 0},
                    new SeatLayout { Fare = 102, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S2", Row=0, Column= 1},
                    new SeatLayout { Fare = 103, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S3" , Row=0, Column= 2},
                    new SeatLayout { Fare = 104, Gender= "F", IsAvailable = true, IsSleeper= false, SeatNo = "S4", Row=0, Column= 3},
                    new SeatLayout { Fare = 105, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S5", Row=0, Column= 4},
                    new SeatLayout { Fare = 106, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S6", Row=0, Column= 5},
                    new SeatLayout { Fare = 107, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S7", Row=0, Column= 6},
                    new SeatLayout { Fare = 108, Gender= "F", IsAvailable = true, IsSleeper= false, SeatNo = "S8", Row=0, Column= 7},
                    new SeatLayout { Fare = 109, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S9", Row=0, Column= 8},
                    new SeatLayout { Fare = 110, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S10", Row=0, Column= 9},
                    new SeatLayout { Fare = 111, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S11", Row=1, Column= 0},
                    new SeatLayout { Fare = 112, Gender= "F", IsAvailable = false, IsSleeper= false, SeatNo = "S12", Row=1, Column= 1},
                    new SeatLayout { Fare = 113, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S13", Row=1, Column=2},
                    new SeatLayout { Fare = 114, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S14", Row=1, Column=3},
                    new SeatLayout { Fare = 115, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S15", Row=1, Column=4},
                    new SeatLayout { Fare = 116, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S16", Row=1, Column=5},
                    new SeatLayout { Fare = 117, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S17", Row=1, Column=6},
                    new SeatLayout { Fare = 118, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S18", Row=1, Column=7},
                    new SeatLayout { Fare = 119, Gender= "M", IsAvailable = true, IsSleeper= false, SeatNo = "S19", Row=1, Column=8},
                    new SeatLayout { Fare = 120, Gender= "M", IsAvailable = false, IsSleeper= false, SeatNo = "S20", Row=1, Column=9}
                };

                return seat;
            }
            else if (routeScheduleId == "0000002")
            {
                var seat = new BusSeatMapModel();
                seat.RouteScheduleId = "00000002";
                seat.CompanyName = "BBB";
                seat.CancellationPolicy = new List<string> { "Can22222222222", "Can2222222", "Can2222222222sss" };
                seat.BordingPoints = new List<BordingPoint>
                {
                    new BordingPoint{ BordingPointId = 1, BordingPointName = "Bp21"},
                    new BordingPoint{ BordingPointId = 2, BordingPointName = "Bp22"},
                };

                seat.LowerDeck = new List<SeatLayout>
                {
                    new SeatLayout { Fare = 101, Gender= "M", IsAvailable = false, IsSleeper= true, SeatNo = "S1", Row=0, Column= 0},
                    new SeatLayout { Fare = 102, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S2", Row=0, Column= 1},
                    new SeatLayout { Fare = 103, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S3" , Row=0, Column= 2},
                    new SeatLayout { Fare = 104, Gender= "F", IsAvailable = true, IsSleeper= true, SeatNo = "S4", Row=0, Column= 3},
                    new SeatLayout { Fare = 105, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S5", Row=0, Column= 4},
                    new SeatLayout { Fare = 106, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S6", Row=0, Column= 5},
                    new SeatLayout { Fare = 107, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S7", Row=1, Column= 0},
                    new SeatLayout { Fare = 108, Gender= "F", IsAvailable = true, IsSleeper= true, SeatNo = "S8", Row=1, Column= 1},
                    new SeatLayout { Fare = 109, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S9", Row=1, Column= 2},
                    new SeatLayout { Fare = 110, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S10", Row=1, Column= 3},
                    new SeatLayout { Fare = 111, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S11", Row=1, Column= 4},
                    new SeatLayout { Fare = 112, Gender= "F", IsAvailable = false, IsSleeper= true, SeatNo = "S12", Row=1, Column= 5},
                    new SeatLayout { Fare = 113, Gender= "M", IsAvailable = false, IsSleeper= true, SeatNo = "S13", Row=2, Column=0},
                    new SeatLayout { Fare = 114, Gender= "M", IsAvailable = false, IsSleeper= true, SeatNo = "S14", Row=2, Column=1},
                    new SeatLayout { Fare = 115, Gender= "M", IsAvailable = false, IsSleeper= true, SeatNo = "S15", Row=2, Column=2},
                    new SeatLayout { Fare = 116, Gender= "F", IsAvailable = false, IsSleeper= true, SeatNo = "S16", Row=2, Column=3},
                    new SeatLayout { Fare = 117, Gender= "M", IsAvailable = false, IsSleeper= true, SeatNo = "S17", Row=2, Column=4},
                    new SeatLayout { Fare = 118, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S18", Row=2, Column=5},
                    new SeatLayout { Fare = 119, Gender= "M", IsAvailable = true, IsSleeper= true, SeatNo = "S19", Row=3, Column=0},
                    new SeatLayout { Fare = 120, Gender= "M", IsAvailable = false, IsSleeper= true, SeatNo = "S20", Row=3, Column=1}
                };

                return seat;
            }
            else if(routeScheduleId == "0000003")
            {
                var seat = new BusSeatMapModel();
                seat.RouteScheduleId = "00000003";
                seat.CompanyName = "CCCC";                
                seat.CancellationPolicy = new List<string> { "Can333333333", "Can333333333333", "Can33333333333333" };
                seat.BordingPoints = new List<BordingPoint>
                {
                    new BordingPoint{ BordingPointId = 3, BordingPointName = "Bp31"},
                    new BordingPoint{ BordingPointId = 3, BordingPointName = "Bp32"},
                };
                

                return seat;
            }
            else 
            {
                var seat = new BusSeatMapModel();
                seat.RouteScheduleId = "00000004";
                seat.CompanyName = "DDDD";
                seat.CancellationPolicy = new List<string> { "Can4", "Can4", "Can4" };
                seat.BordingPoints = new List<BordingPoint>
                {
                    new BordingPoint{ BordingPointId = 3, BordingPointName = "Bp41"},
                    new BordingPoint{ BordingPointId = 3, BordingPointName = "Bp42"},
                };


                return seat;
            }

        }
    }
}